<?php
require('../kernel/config.php');
require(PATH_ABS.'/admin/login.php');
$a_conf = ABConf::getAll();
$o_db = dbConnect::getInstance(array('server' => $a_conf['server'], 'user' =>$a_conf['user'], 'pass' => $a_conf['keypass'], 'dbname' => $a_conf['dbname']));
$o_tpl =  new ABTemplate('admin/index', 'page');
$o_dbpost  = new ABPost($o_db);
if(ABApi::hasAction('delete')){
	$o_tpl->adelete =  true;
	$o_tpl->pid =(int)ABApi::action('delete');
}elseif(ABApi::hasAction('edit')){
	$i_id = (int) ABApi::action('edit');
	ABApi::redirect("admin/write.php?edit=$i_id",true);
}elseif(ABAPi::hasAction('erase')){
	$b_result =$o_dbpost->delete(ABAPi::action('erase'));
	if($b_result){
		$o_tpl->ok = 'Entrada eliminada correctamente';
	}else
		$o_tpl->error = 'Error al tratar de eliminar la entrada';
}
$o_tpl->entry=$o_dbpost->toindex();
$o_tpl->ptitle = 'Administración de paginas';
ABApi::setCommonAdmin($o_tpl);
$o_tpl->parse();
?>
